{include file="public/header" /}
<style>
	
	#div-slide_show_pic{display:flex;flex-wrap:wrap;}
	.item-img {
		flex-direction: column;
		display: flex;
		margin-right: 18px;
		margin-bottom:17px;width:12%;text-align:center;
	}
	.item-img img{max-width: 100%;}
	.delMultipleImgs4{text-align:center;}
</style>
<style>

@font-face {

	font-family: 'FontAwesome';

	src: url('http://libs.baidu.com/fontawesome/4.1.0/fonts/fontawesome-webfont.eot?v=4.1.0');

	src: url('http://libs.baidu.com/fontawesome/4.1.0/fonts/fontawesome-webfont.eot?#iefix&v=4.1.0') format('embedded-opentype'), url('/css/fonts/fontawesome-webfont.woff?v=4.1.0') format('woff'), url('/css/fonts/fontawesome-webfont.ttf?v=4.1.0') format('truetype'), url('http://libs.baidu.com/fontawesome/4.1.0/fonts/fontawesome-webfont.svg?v=4.1.0#fontawesomeregular') format('svg');

	font-weight: normal;

	font-style: normal;

}

.icon-plus:before                 { content: "\f067"; }
.icon-minus:before                { content: "\f068"; }
[class^="icon-"]:before, [class*=" icon-"]:before {
  font-family: FontAwesome;
  font-weight: normal;
  font-style: normal;
  display: inline-block;
  text-decoration: inherit;
}
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加/编辑</h5>
                </div>
                <div class="ibox-content">

					<form id="formEdit" method="post" class="form-horizontal" action="{:url('school/edit')}">

	
						<div class="form-group">
							<label class="col-sm-3 control-label"><span style="color:red;">*&nbsp;</span>学院名称</label>
							<div class="input-group col-sm-4">
								<input type="text" name="college_name" placeholder="请输入" autocomplete="off" class="form-control"
									   value="{:isset($list.college_name)?$list.college_name:''}" >
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label"><span style="color:red;">&nbsp;</span>学院编号</label>
							<div class="input-group col-sm-4">
								<input type="text" name="college_code" placeholder="请输入" autocomplete="off" class="form-control"
									   value="{:isset($list.college_code)?$list.college_code:''}" >
							</div>
						</div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">所在地区：</label>
                            <div class="input-group col-sm-4">
                                <select class="m-b chosen-select" name="province_id" id="province_id">
                                    <option value="">==请选择==</option>
                                    {if !empty($sheng_list)}
                                        {foreach name="sheng_list" item="vo"}
                                            <option value="{$vo.id}" {if condition="isset($list['province_id']) and ($list['province_id'] eq $vo['id'])"}selected{/if}>{$vo.name}</option>
                                        {/foreach}
                                    {/if}
                                </select>
                                <select class="m-b chosen-select" name="city_id" id="city_id">
                                    <option value="">==请选择==</option>
                                    {if !empty($city_list)}
                                        {foreach name="city_list" item="vo"}
                                            <option value="{$vo.id}" {if condition="isset($list['city_id']) and ($list['city_id'] eq $vo['id'])"}selected{/if}>{$vo.name}</option>
                                        {/foreach}
                                    {/if}
                                </select>
                                <select class=" m-b chosen-select" name="district_id" id="xian_id">
                                    <option value="">==请选择==</option>
                                    {if !empty($xian_list)}
                                        {foreach name="xian_list" item="vo"}
                                            <option value="{$vo.id}" {if condition="isset($list['xian_id']) and ($list['xian_id'] eq $vo['id'])"}selected{/if}>{$vo.name}</option>
                                        {/foreach}
                                    {/if}
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">院校类型：</label>
                            <div class="input-group col-sm-4">
                                <select class="form-control m-b chosen-select" name="school_type" id="school_type">
                                    <option value="">==请选择==</option>
                                    {if !empty($type_list)}
                                        {foreach name="type_list" item="vo"}
                                            <option value="{$vo.id}" {if condition="isset($list['school_type']) and ($list['school_type'] eq $vo.id)"}selected{/if}>{$vo.title}</option>
                                        {/foreach}
                                    {/if}
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">院校特色：</label>
                            <div class="input-group col-sm-4">
                                <select name="school_tese"  multiple="multiple" xm-select='selectId'>
                                    <option value="">==请选择==</option>
                                    {if !empty($type_list)}
                                        {foreach name="tese_list" item="vo"}
                                            <option value="{$vo.id}" {in name="vo['id']" value="$list['school_tese']"}selected{/in}>{$vo.title}</option>
                                        {/foreach}
                                    {/if}
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">院校性质：</label>
                            <div class="input-group col-sm-4">
                                <select class="form-control m-b chosen-select" name="school_xingzhi" id="school_xingzhi">
                                    <option value="">==请选择==</option>
                                    {if !empty($xingzhi_list)}
                                        {foreach name="xingzhi_list" item="vo"}
                                            <option value="{$vo.id}" {if condition="isset($list['school_xingzhi']) and ($list['school_xingzhi'] eq $vo.id)"}selected{/if}>{$vo.title}</option>
                                        {/foreach}
                                    {/if}
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">院校性质2：</label>
                            <div class="input-group col-sm-4">
                                <select class="form-control m-b chosen-select" name="school_xingzhi2" id="school_xingzhi2">
                                    <option value="">==请选择==</option>
                                    {if !empty($xingzhi_list2)}
                                        {foreach name="xingzhi_list2" item="vo"}
                                            <option value="{$vo.id}" {if condition="isset($list['school_xingzhi2']) and ($list['school_xingzhi2'] eq $vo.id)"}selected{/if}>{$vo.title}</option>
                                        {/foreach}
                                    {/if}
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">院校所属：</label>
                            <div class="input-group col-sm-4">
                                <select class="form-control m-b chosen-select" name="school_suoshu" id="school_suoshu">
                                    <option value="">==请选择==</option>
                                    {if !empty($suoshu_list)}
                                        {foreach name="suoshu_list" item="vo"}
                                            <option value="{$key}" {if condition="isset($list['school_suoshu']) and ($list['school_suoshu'] eq $key)"}selected{/if} >{$vo}</option>
                                        {/foreach}
                                    {/if}
                                </select>
                            </div>
                        </div>
						<div class="form-group">
							<label class="col-sm-3 control-label"><span style="color:red;">*&nbsp;</span>热度</label>
							<div class="input-group col-sm-4">
								<input type="text" name="hot_nums" placeholder="请输入" autocomplete="off" class="form-control" style="width:200px;" value="{:isset($list.hot_nums)?$list.hot_nums:''}" ><span style="height: 33px;line-height: 33px;">万</span>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label"><span style="color:red;">*&nbsp;</span>难易指数</label>
							<div class="input-group col-sm-4">
								<input type="text" name="difficult_nums" placeholder="请输入" autocomplete="off" class="form-control"
									   value="{:isset($list.difficult_nums)?$list.difficult_nums:''}" >
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label"><span style="color:red;">&nbsp;</span>全国排名</label>
							<div class="input-group col-sm-4">
								<input type="text" name="ranking" placeholder="请输入" autocomplete="off" class="form-control"
									   value="{:isset($list.ranking)?$list.ranking:''}" >
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label"><span style="color:red;">*&nbsp;</span>建立年份</label>
							<div class="input-group col-sm-4">
								<input type="text" name="year" placeholder="请输入" autocomplete="off" class="form-control" value="{:isset($list.year)?$list.year:''}" >
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label"><span style="color:red;">*&nbsp;</span>硕士点</label>
							<div class="input-group col-sm-4">
								<input type="text" name="shuoshi_count" placeholder="请输入" autocomplete="off" class="form-control" value="{:isset($list.shuoshi_count)?$list.shuoshi_count:''}" >
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label"><span style="color:red;">*&nbsp;</span>博士点</label>
							<div class="input-group col-sm-4">
								<input type="text" name="boshi_count" placeholder="请输入" autocomplete="off" class="form-control" value="{:isset($list.boshi_count)?$list.boshi_count:''}" >
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label"><span style="color:red;">&nbsp;</span>学院校徽</label>
							<div class="input-group col-sm-4">
								<span>{notempty name="$list['cover_image']"}<img style="margin-left: 10px;height:80px;" src="{:isset($list.cover_image)?$list.cover_image:''}">{/notempty}</span>
								<input type="text" class="file_value form-control" value="{:isset($list.cover_image)?$list.cover_image:''}" name="cover_image" lay-verify="uploadimg">
								<button type="button" class="layui-btn layui-btn-primary upload_img upload_img1" lay-data="{id:1}"><i class="layui-icon">&#xe67c;</i> 上传</button>   
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label"><span style="color:red;">&nbsp;</span>详情页图片</label>
							<div class="input-group col-sm-4">
								<span>{notempty name="$list['school_img']"}<img style="margin-left: 10px;height:80px;" src="{:isset($list.school_img)?$list.school_img:''}">{/notempty}</span>
								<input type="text" class="file_value form-control" value="{:isset($list.school_img)?$list.school_img:''}" name="school_img" lay-verify="uploadimg">
								<button type="button" class="layui-btn layui-btn-primary upload_img upload_img2" lay-data="{id:2}"><i class="layui-icon">&#xe67c;</i> 上传</button>   
							</div>
						</div>
						
						<div class="form-group">
							<label class="col-sm-3 control-label"><span style="color:red;">&nbsp;</span>学院简介</label>
							<div class="input-group col-sm-6">
								<textarea name="intro" style="width:100%;height:300px;">{:isset($list.intro)?$list.intro:''}</textarea>
							</div>
						</div>
						<!-- <div class="form-group">
							<label class="col-sm-3 control-label"><span style="color:red;">&nbsp;</span>教育资源(师资力量)</label>
							<div class="input-group col-sm-6">
								<textarea name="shizi" style="width:100%;height:300px;">{:isset($list.shizi)?$list.shizi:''}</textarea>
							</div>
						</div> -->
                        <div class="form-group">
                            <label class="col-sm-3 control-label">院校风采：</label>
                            <div class="input-group col-sm-9">
                                <input type="hidden" class="other_pics" value="{$list['img_fengcai']??''}" name="img_fengcai" >
								<img src="/static/images/add1.png" class="multiple_upload_img" />
							  
								<span id="div-slide_show_pic">
									{if condition="$list['img_fengcai'] neq ''"}
									{volist name="img_fengcai" id="vo"}
									<em class="item-img">
									<a target="_bank" href="{$vo}">
									<img src="{$vo}" style="height:80px;"></a>
									<a class="delMultipleImgs" href="javascript:">删除</a>
									</em>
									{/volist}
									{/if}
								</span>
                            </div>
                        </div>
						<div class="form-group">
							<label class="col-sm-3 control-label"><span style="color:red;">&nbsp;</span>学院地址</label>
							<div class="input-group col-sm-4">
								<input type="text" name="address" placeholder="请输入" autocomplete="off" class="form-control"
									   value="{:isset($list.address)?$list.address:''}" >
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label"><span style="color:red;">&nbsp;</span>学院招生电话</label>
							<div class="input-group col-sm-4">
								<input type="text" name="call_number" placeholder="请输入" autocomplete="off" class="form-control"
									   value="{:isset($list.call_number)?$list.call_number:''}" >
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label"><span style="color:red;">&nbsp;</span>学院官网</label>
							<div class="input-group col-sm-4">
								<input type="text" name="web_site" placeholder="请输入" autocomplete="off" class="form-control"
									   value="{:isset($list.web_site)?$list.web_site:''}" >
							</div>
						</div>
						
						<div class="form-group syiliu_group">
							<label class="col-sm-3 control-label"><span style="color:red;">&nbsp;</span>双一流学科</label>
							<div> 
								<div class="input-group col-sm-9 field" style="display:none;float: right;"> 
									<input type="text" name="" placeholder="请输入数量" autocomplete="off" class="nums" value="" >
									<textarea name="" placeholder="请输入学科" class="major" style="width:50%;height:150px;"></textarea>
									<span style="margin-right:5px;float: left;height: 33px;line-height: 33px;" class="icon-minus "></span>
								</div>
								<span style="margin-right:5px;float: left;height: 33px;line-height: 33px;" class="icon-plus "></span>
							</div>
							<div class="group3">
							{notempty name="list['syiliu']"}
							{volist name="list['syiliu']" id="vo"}
							<div class="input-group col-sm-9 field" style="float: right;">
								<input type="text" name="syiliu[{$key}][nums]" placeholder="请输入数量" autocomplete="off" class="nums" value="{$vo['nums']??''}" >
								<textarea name="syiliu[{$key}][major]" class="major" placeholder="请输入学科" style="width:50%;height:150px;">{:isset($vo.major)?$vo.major:''}</textarea>
								<span style="margin-right:5px;float: left;height: 33px;line-height: 33px;" class="icon-minus"></span>
							</div>
							{/volist}
							{/notempty}
							</div>
						</div>
						
						<div class="form-group group1">
							<label class="col-sm-3 control-label"><span style="color:red;">&nbsp;</span>学科评估</label>
								{notempty name="list['pinggu']"}
								{volist name="list['pinggu']" id="vo"}
								<div class="input-group col-sm-9 field" style="float: right;">
									<input type="text" name="pinggu[{$key}][nums]" placeholder="请输入数量" autocomplete="off" class="nums" value="{$vo['nums']??''}" >
									<textarea class="result" name="pinggu[{$key}][result]" placeholder="请输入专业" style="width:50%;height:150px;">{:isset($vo.result)?$vo.result:''}</textarea>
									<span style="margin-right:5px;float: left;height: 33px;line-height: 33px;" class="{if $key eq 0}icon-plus{else}icon-minus{/if}"></span>
								</div>
								{/volist}
								{else}
								<div class="input-group col-sm-9 field" style="float: right;">
									<input type="text" name="pinggu[0][nums]" placeholder="请输入数量" autocomplete="off" class="nums" value="" >
									<textarea name="pinggu[0][result]" placeholder="请输入专业" class="result" style="width:50%;height:150px;"></textarea>
									<span style="margin-right:5px;float: left;height: 33px;line-height: 33px;" class="icon-plus "></span>
								</div>
								{/notempty}
						</div>
						
						<div class="form-group tese_major_group">
							<label class="col-sm-3 control-label"><span style="color:red;">&nbsp;</span>特色专业</label>
							<div> 
								<div class="input-group col-sm-9 field" style="display:none;float: right;"> 
									<input type="text" name="" placeholder="请输入专业层次" autocomplete="off" class="title" value="" >
									<input type="text" name="" placeholder="请输入数量" autocomplete="off" class="nums" value="" >
									<textarea name="" placeholder="请输入专业" class="major" style="width:50%;height:150px;"></textarea>
									<span style="margin-right:5px;float: left;height: 33px;line-height: 33px;" class="icon-minus "></span>
								</div>
								<span style="margin-right:5px;float: left;height: 33px;line-height: 33px;" class="icon-plus "></span>
							</div>
							<div class="group2">
							{notempty name="list['tese_major']"}
							{volist name="list['tese_major']" id="vo"}
							<div class="input-group col-sm-9 field" style="float: right;">
								<input type="text" name="tese_major[{$key}][title]" placeholder="请输入专业层次" autocomplete="off" class="title" value="{$vo['title']}" >
								<input type="text" name="tese_major[{$key}][nums]" placeholder="请输入数量" autocomplete="off" class="nums" value="{$vo['nums']??''}" >
								<textarea name="tese_major[{$key}][major]" class="major" style="width:50%;height:150px;">{:isset($vo.major)?$vo.major:''}</textarea>
								<span style="margin-right:5px;float: left;height: 33px;line-height: 33px;" class="icon-minus"></span>
							</div>
							{/volist}
							{/notempty}
							</div>
						</div>
												
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
								<input type="hidden" name="id" value="{:isset($list['id'])?$list['id']:''}">
                                <button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;&nbsp;
                                <a class="btn btn-danger" href="javascript:history.go(-1);"><i class="fa fa-close"></i> 返回</a>
                            </div>
                        </div>
					</form>

                </div>
            </div>

        </div>
    </div>
</div>
{include file="public/footer" /}
<link rel="stylesheet" href="/static/admin/form-select/formSelects-v4.css" media="all"/>
<script type="text/javascript" src="/static/admin/js/layui.js"></script>
<script type="text/javascript" src="/static/admin/js/select2/select2.js"></script>
<link href="/static/admin/js/select2/css/select2.min.css?20191202" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="/static/admin/css/layui.css" media="all"/>
<script type="text/javascript">
layui.config({
	base: '/static/admin/form-select/' //此处路径请自行处理, 可以使用绝对路径
}).extend({
	formSelects: 'formSelects-v4'
});
layui.use(['formSelects','upload'], function () {
	var formSelects = layui.formSelects;
	var upload = layui.upload;
    var multiple_images = {$img_fengcai_js|html_entity_decode};
	if(multiple_images.length == 0){
		multiple_images = [];
	}
	function delMultipleImgs(this_img){
		//获取下标
		console.log(this_img);
		//var subscript=$("#div-slide_show_pic item-img").index(this_img);
		var subscript=this_img.parent().children().index(this_img);
		console.log($("#div-slide_show item-img"));
		console.log(subscript);
		//删除图片
		this_img.remove();
		console.log(multiple_images);
		//删除数组
		multiple_images.splice(subscript, 1);
		//重新排序
		//multiple_images.sort();
		console.log(multiple_images);
		$('.other_pics').val(multiple_images);
		//返回
		return ;
	}
	$("body").delegate(".delMultipleImgs","click",function(){
		//delMultipleImgs(this);
		//delMultipleImgs($(this).parent('.item-img').get(0));
		delMultipleImgs($(this).parent('.item-img'));
	})
	upload.render({
		elem: '.multiple_upload_img',
		url: "{:url('Upload/upload_oss')}",
		accept:'file',
		exts:'jpg|png|jpeg',
		multiple: true,
		before: function(obj){
		
		},
		done: function(data){
			var icon=5;
			if(multiple_images.length>20){
				layer.msg('最多20张图片', {icon:5,time: 1500});
				return false;
			}
			if(!data.code){
				icon=6;
				console.log(multiple_images);
				multiple_images.push(data.data.src); 
				$('.other_pics').val(multiple_images);
				
				$('#div-slide_show_pic').append('<em class="item-img"><img src="'+ data.data.src +'" alt=" " title="" class="layui-upload-img" style="height:80px;"><a class="delMultipleImgs" href="javascript:">删除</a></em>&nbsp;')
			}
			layer.msg(data.msg, {icon:icon,time: 1500});
		},
		error: function(){
			layer.msg('上传失败', {icon:5,time: 1500});
		}
	});
	
	//单图上传
	upload.render({
		elem: '.upload_img',
		url: "{:url('Upload/upload_oss')}",
		accept:'images',
		acceptMime:'image/*',
		done: function(data){
			var id = this.id;
			var icon=5;
			if(!data.code){
				icon=6;
				//this.elem.prev().prev("span").html('<img style="margin-left: 10px;height:80px;" src="'+data.data.src+'">');
				//this.elem.prev(".file_value").val(data.data.src);
				$(".upload_img"+id).prev().prev("span").html('<img style="margin-left: 10px;height:80px;" src="'+data.data.src+'">');
				$(".upload_img"+id).prev(".file_value").val(data.data.src);
			}
			layer.msg(data.msg, {icon:icon,time: 1500});
		},
		error: function(){
			layer.msg('上传失败', {icon:icon,time: 1500});
		}
	});
});
</script>

<script type="text/javascript">
	$('.select2').select2({
		allowClear: true,
		width: '80%',
		minimumResultsForSearch: 1,
		placeholder: {
			'id': "",
			'text': "请选择",
		}
	});
	
	$("#province_id").change(function(){
		var province_id = $(this).val();
		$.get("{:url('school/get_area_child')}",{'id':province_id,'act':2},function(e){
			$("#city_id").html(e);
		})
	})
	$("#city_id").change(function(){
		var city_id = $(this).val();
		$.get("{:url('school/get_area_child')}",{'id':city_id,'act':3},function(e){
			$("#xian_id").html(e);
		})
	})
	
		//双一流学科
		var j = "{$list['syiliu_count']}";
		$('.syiliu_group').on('click','.icon-plus',function(){
			var html = $(this).parent().find('.field').clone();
			html.css('display','');
			html.find(".nums").attr('name','syiliu['+j+'][nums]');
			html.find(".major").attr('name','syiliu['+j+'][major]');
			$(this).closest('.form-group').children(".group3").append(html); 
			j++;	

		})   
		$('.group3').on('click','.icon-minus',function(){
			$(this).closest('.field').remove();
		})
		
	
		//学科评估
		var i = "{$list['pinggu_count']}";
		i++;
		$('.group1').on('click','.icon-plus',function(){
			var html = $(this).closest('.field').clone();
			html.find('.icon-plus').removeClass('icon-plus').addClass('icon-minus');
			html.find('.nums').val('');
			html.find('.result').val('');
			html.find(".nums").attr('name','pinggu['+i+'][nums]');
			html.find(".result").attr('name','pinggu['+i+'][result]');
		   
			//$(this).closest('.field').after(html);
			$(this).closest('.form-group').append(html); 
		
			i++;	

		})   
		$('.group1').on('click','.icon-minus',function(){
			$(this).closest('.field').remove();
			$(".group1 .field").each((j,item)=>{
				$(item).find(".nums").attr('name','pinggu['+j+'][nums]');
				$(item).find(".result").attr('name','pinggu['+j+'][result]');
			});
			i--;
		})
		
		//特色专业
		var j = "{$list['tese_major_count']}";
		$('.tese_major_group').on('click','.icon-plus',function(){
			var html = $(this).parent().find('.field').clone();
			html.css('display','');
			html.find(".title").attr('name','tese_major['+j+'][title]');
			html.find(".nums").attr('name','tese_major['+j+'][nums]');
			html.find(".major").attr('name','tese_major['+j+'][major]');
			$(this).closest('.form-group').children(".group2").append(html); 
			j++;	

		})   
		$('.group2').on('click','.icon-minus',function(){
			$(this).closest('.field').remove();
		})
		
    //提交
    $(function(){
        $('#formEdit').ajaxForm({
            beforeSubmit: checkForm, 
            success: complete, 
            dataType: 'json'
        });
        
        function checkForm(){
            if( '' == $.trim($('input[name="college_name"]').val())){
                layer.msg('请输入学院名称',{icon:2,time:1500,shade: 0.1}, function(index){
                layer.close(index);
                });
                return false;
            }
        }


        function complete(data){
            if(data.code==1){
                layer.msg(data.msg, {icon: 6,time:1500,shade: 0.1}, function(index){
                    window.location.href="{:url('school/index')}";
                });
            }else{
                layer.msg(data.msg, {icon: 5,time:1500,shade: 0.1});
                return false;   
            }
        }
     
    });

</script>
</body>
</html>